from django.db import models
from django.utils import timezone
import datetime


# Create your models here.

class Question(models.Model):
    def __str__(self):
        return self.question_text

    question_text = models.CharField(max_length=200)
    pub_date = models.DateTimeField('date published')


class Choice(models.Model):
    def __str__(self):
        return self.choice_text

    question = models.ForeignKey(Question, on_delete=models.CASCADE)
    choice_text = models.CharField(max_length=200)
    votes = models.IntegerField(default=0)

    def was_published_recently(self):
        return self.pub_date >= timezone.now() - datetime.timedelta(days=1)


class Assets(models.Model):
    def __str__(self):
        return self.assets_question

    assets_question = models.CharField(max_length=200)


class UserRisk(models.Model):
    def __str__(self):
        return self.id

    id = models.AutoField(primary_key=True)
    mobile_numer = models.CharField(max_length=200)
    risk_num = models.CharField(max_length=200)
    rowkey = models.CharField(max_length=200, default="")


class Finance(models.Model):
    rowkey = models.CharField(max_length=200, default="")
    assets_score = models.CharField(max_length=200, default=0)
    assets=models.ForeignKey(Assets, on_delete=models.CASCADE)


